/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "marca", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Marca.findAll", query = "SELECT m FROM Marca m"),
    @NamedQuery(name = "Marca.findByMarCod", query = "SELECT m FROM Marca m WHERE m.marCod = :marCod"),
    @NamedQuery(name = "Marca.findByMarDecri", query = "SELECT m FROM Marca m WHERE m.marDecri = :marDecri")})
public class Marca implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "mar_cod", nullable = false)
    private Integer marCod;
    @Size(max = 20)
    @Column(name = "mar_decri", length = 20)
    private String marDecri;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "marcaMarCod")
    private Collection<Productos> productosCollection;

    public Marca() {
    }

    public Marca(Integer marCod) {
        this.marCod = marCod;
    }

    public Integer getMarCod() {
        return marCod;
    }

    public void setMarCod(Integer marCod) {
        this.marCod = marCod;
    }

    public String getMarDecri() {
        return marDecri;
    }

    public void setMarDecri(String marDecri) {
        this.marDecri = marDecri;
    }

    @XmlTransient
    public Collection<Productos> getProductosCollection() {
        return productosCollection;
    }

    public void setProductosCollection(Collection<Productos> productosCollection) {
        this.productosCollection = productosCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (marCod != null ? marCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Marca)) {
            return false;
        }
        Marca other = (Marca) object;
        if ((this.marCod == null && other.marCod != null) || (this.marCod != null && !this.marCod.equals(other.marCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.Marca[ marCod=" + marCod + " ]";
    }
    
}
